package com.pureut.storage.util;


import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author: CM
 * @date: 2023/6/28  15:39
 */
public class DateUtilss {

    /**
     * JAVA计算两个日期相差多少天
     * @param date1str
     * @param date2str
     * @return
     */
    public static int daysBetween(String date1str,String date2str) throws ParseException {
        int count = 0;
        if("".equals(date1str) || date1str == null || "".equals(date2str) || date2str == null) {
            return count;
        }
        SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd");
        Date date1 = format.parse(date1str);
        Date date2 = format.parse(date2str);
        count = Math.abs((int) ((date1.getTime() - date2.getTime()) / (1000*3600*24)));
        return count;
    }

}
